8672. Square root

 

Given a positive integer n. Find its square root.

 

Input. One positive integer n (1  n ≤ 1016).

 

Output. Print the square root of the given number rounded to 6 decimal places.

 

Sample input 1

Sample output 1

10

1.000000

 

 

Sample input 2

Sample output 2

1000000

1000.000000

 

 

SOLUTION

mathematics

 

Algorithm analysis

To compute the square root, use the sqrt function from the <math.h> library.

 

Algorithm implementation

Read the input value of x.

 

scanf("%lf",&x);

 

Compute and print the square root of the number x.

 

y = sqrt(x);

printf("%.6lf\n",y);

 

Java implementation

 

import java.util.*;

 

public class Main

{

  public static void main(String[] args)

  {

    Scanner con = new Scanner(System.in);

    double x  = con.nextDouble();

    double y = Math.sqrt(x);

    System.out.printf("%6f\n",y);

    con.close();

  }

}

 

Python implementation

 

import math

 

Read the input value of x.

 

x = float(input())

 

Compute and print the square root of the number x.

 

y = math.sqrt((x))

print(y)